<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ page contentType="text/html;charset=utf-8"%>
<!DOCTYPE html>
<html>
<head>
<title>Kai Pro系统用户登录</title>
<%
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ request.getContextPath() + "/";
%>
<base href="<%=basePath%>">
<script src="<%=basePath%>plugin/jquery-easyui-1.4.3/jquery.min.js"
	type="text/javascript" charset="utf-8"></script>
<script
	src="<%=basePath%>plugin/jquery-easyui-1.4.3/jquery.easyui.min.js"
	type="text/javascript" charset="utf-8"></script>
<script
	src="<%=basePath%>plugin/jquery-easyui-1.4.3/extend.js"
	type="text/javascript" charset="utf-8"></script>	
	
<link
	href="<%=basePath%>plugin/jquery-easyui-1.4.3/themes/default/easyui.css"
	rel="stylesheet" type="text/css" />
<link href="<%=basePath%>plugin/jquery-easyui-1.4.3/themes/icon.css"
	rel="stylesheet" type="text/css" />
<link href="<%=basePath%>plugin/jquery-easyui-1.4.3/demo/demo.css"
	rel="stylesheet" type="text/css" />
<script
	src="<%=basePath%>plugin/jquery-easyui-1.4.3/locale/easyui-lang-zh_CN.js"
	type="text/javascript" charset="utf-8"></script>
<script
	src="<%=basePath%>plugin/syUtilis.js"
	type="text/javascript" charset="utf-8"></script>
	
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<script>
	function closes() {
		$("#Loading").fadeOut("normal", function() {
			$(this).remove();
		});
	}
	$.parser.onComplete = function() {
		closes();	
	}
</script>

</head>
<body>
	<div id='Loading'
		style="position: absolute; z-index: 1000; top: 0px; left: 0px; width: 100%; height: 100%; background: #DDDDDB; text-align: center; padding-top: 20%;">
	</div>

	<div id="win" class="easyui-window" style="width: 400px; height: 200px"
		data-options="title:'用户登录',
		iconCls:'icon-key',
	    modal:true,
	    closable:false,
	    resizable:false,
	    collapsible:false,
	    maximizable:false,
	    minimizable:false,
	    shadow:true">
		<div class="easyui-layout" data-options="fit:true">
			<div data-options="region:'north'" style="height: 110px">
				<form id='login_form'>
					<table style="margin-left: 105px; margin-top: 20px;">
						<tr>
							<td><label for="name">用户名:</label></td>
							<td><input class="easyui-validatebox textbox" type="text"
								name="login_name"
								data-options="required:true,missingMessage:'请输入用户名'" /></td>
						</tr>
						<tr>
							<td></td>
							<td></td>
						</tr>
						<tr>
							<td></td>
							<td></td>
						</tr>
						<tr>
							<td><label for="name">密&nbsp;&nbsp;码:</label></td>
							<td><input class="easyui-validatebox textbox"
								type="password" name="login_password"
								data-options="required:true,missingMessage:'请输入密码'" /></td>
						</tr>

					</table>
				</form>
			</div>
			<div data-options="region:'center'" style="text-align: center">
				<br /> <a id="customer_login" href="javascript:void(0);"
					class="easyui-linkbutton" data-options="iconCls:'icon-ok'">客户登录</a>
				&nbsp;&nbsp; <a id="admin_login" href="javascript:void(0);"
					class="easyui-linkbutton" data-options="iconCls:'icon-ok'">管理员登录</a>
				&nbsp;&nbsp; <a id="reset" href="javascript:void(0);"
					class="easyui-linkbutton" data-options="iconCls:'icon-reload'">重置</a>
				&nbsp;&nbsp; <a id="user_reg_btn" class="easyui-linkbutton"
					data-options="iconCls:'icon-user_add'"
					onclick="$('#registModal').window('open')">注册</a>
			</div>
		</div>
	</div>

	<div id="registModal" class="easyui-window" title="注册"
		data-options="modal:true,closed:true,maximizable:false,
	    minimizable:false"
		style="width: 500px; padding: 10px;">
		<div data-options="region:'north'">
			<form id='regist_form' method="post">
				<table style="margin: auto;">
					<tr>
						<td><label for="name">用户名:</label></td>
						<td><input class="easyui-validatebox textbox" type="text"
							name="login_name"
							data-options="required:true,missingMessage:'请输入用户名'" /></td>
					</tr>
					<tr>
						<td></td>
						<td></td>
					</tr>
					<tr>
						<td><label for="name">密&nbsp;&nbsp;码:</label></td>
						<td><input id="password" class="easyui-validatebox textbox"
							type="password" name="login_password"
							data-options="required:true,missingMessage:'请输入密码'" /></td>
					</tr>
					<tr>
						<td></td>
						<td></td>
					</tr>

					<tr>
						<td><label for="name">重复密码:</label></td>
						<td><input class="easyui-validatebox textbox" type="password"
							name="repassword" data-options="required:true"
							validType="equalTo['#password']" /></td>
					</tr>
					<tr>
						<td></td>
						<td></td>
					</tr>
					<tr>
						<td><label for="name">真实姓名:</label></td>
						<td><input class="easyui-validatebox textbox" type="text"
							name="user_name"
							data-options="required:true,missingMessage:'请输入真实姓名'" /></td>
					</tr>
					<tr>
						<td></td>
						<td></td>
					</tr>
					<tr>
						<td><label for="name">公司名称:</label></td>
						<td><input class="easyui-textbox" name="companyName"
							data-options="multiline:true" style="height: 50px;" /></td>
					</tr>
					<tr>
						<td></td>
						<td></td>
					</tr>
					<tr>
						<td><label for="name">公司地址:</label></td>
						<td><input class="easyui-textbox" name="companyAddr"
							data-options="multiline:true" style="height: 50px;" /></td>
					</tr>
					<tr>
						<td></td>
						<td></td>
					</tr>
					<tr>
						<td><label for="name">公司电话:</label></td>
						<td><input class="easyui-textbox" name="companyPhone"
							data-options="validType:'tel'" /></td>
					</tr>
					<tr>
						<td></td>
						<td></td>
					</tr>
					<tr>
						<td><label for="name">手机：</label></td>
						<td><input class="easyui-textbox" name="user_mobile"
							data-options="validType:'mobile'" /></td>
					</tr>
					<tr>
						<td></td>
						<td></td>
					</tr>
				<tr>
					<td><label for="alipayNo">支付宝账号：</label></td>
					<td><input class="easyui-textbox" name="alipayNo"/></td>
				</tr>
				<tr>
					<td></td>
					<td></td>
				</tr>				
					<tr>
						<td><label for="name">QQ号：</label></td>
						<td><input class="easyui-textbox" name="qqNumber"
							data-options="validType:'QQ'" /></td>
					</tr>
					<tr>
						<td></td>
						<td></td>
					</tr>
					<tr>
						<td><label for="name">当前业务：</label></td>
						<td><select class="easyui-combobox" name="transaction">
								<option value="FBA换标">FBA换标</option>
								<option value="FBA中转">FBA中转</option>
								<option value="海外仓储">海外仓储</option>
								<option value="FBA退货业务">FBA退货业务</option>
						</select></td>
					</tr>
					<tr>
						<td></td>
						<td></td>
					</tr>
					<tr>
						<td><label for="name">主要产品：</label></td>
						<td><input class="easyui-textbox" name="product" /></td>
					</tr>
					<tr>
						<td></td>
						<td></td>
					</tr>
					<tr>
						<td><label for="name">常用email：</label></td>
						<td><input class="easyui-textbox" name="user_email"
							data-options="validType:'email'" /></td>
					</tr>
				</table>
			</form>
		</div>
		<div data-options="region:'center'" style="text-align: center">
			<br /> <a id="customer_regis" href="javascript:void(0);"
				class="easyui-linkbutton" data-options="iconCls:'icon-ok'">注册</a>
		</div>
	</div>

	<div id="alertModal" class="easyui-window"
		style="width: 400px; height: 200px; padding-left: 10px"
		data-options="title:'提示信息',
	    modal:true,
	    closed:true,
	    closable:false,
	    resizable:false,
	    collapsible:false,
	    maximizable:false,
	    minimizable:false,
	    shadow:true">
		<p>
			<span id="alert_msg"></span>即将进入登录页面...
		</p>
		<div id="p_bar" class="easyui-progressbar"
			style="width: 300px; margin: auto"></div>
	</div>


	<script type="text/javascript">
		$.extend($.fn.validatebox.defaults.rules, {
			/*必须和某个字段相等*/
			equalTo : {
				validator : function(value, param) {
					return $(param[0]).val() == value;
				},
				message : '两次输入不一致'
			}
		});

		function a(){
			var value = $('#p_bar').progressbar('getValue');
			if (value < 100) {
				value += Math.floor(Math.random() * 10);
				$('#p_bar').progressbar('setValue', value);
				setTimeout("a()",100);
			} else window.location.href = sybp() + '/login/welcome';
		}
		
		$("#customer_regis").click(function() {
			$("#regist_form").form('submit', {
				url : "login/regist.do",
				onSubmit : function() {
					var isValid = $(this).form('validate');
					return isValid;
				},

				success : function(data) {
					//$.messager.alert('提示信息', data);
					var data = eval("(" + data + ")");
					$.messager.alert('提示信息', data.msg);
					if (data.success == true) {
						//window.location.href =  sybp() + '/login/welcome';
						window.location.href ='<%=basePath%>login/welcome';
					} else {
						//$("#alertModal").window('open');
						//$("#alert_msg").text(data.msg);
						//a();
					}
				}
			});
		});

		/**点击重置*/
		$("#reset").click(function() {
			$("input[name='login_name']").val('');
			$("input[name='login_password']").val('');
		});
		/**管理员登录按钮*/
		$("#admin_login")
				.click(
						function() {
							$("#login_form")
									.form(
											'submit',
											{
												url : 'login/admin/validate.do',
												onSubmit : function() {//发送前操作    
													var isValid = $(this).form(
															'validate');
													return isValid; // 返回false终止表单提交
												},
												success : function(data) {
													var data = eval('(' + data
															+ ')');
													if (data.success == true) {
														window.location.href = '<%=basePath%>login/admin/home/index';
														//location.replace(sybp() + '/login/admin/home/index');
													} else {
														$.messager
																.alert(
																		'警告',
																		'<strong><center>'
																				+ data.msg
																				+ '</center></strong>');
													}
												}
											});
						});
		/**客户登录按钮*/
		$("#customer_login")
				.click(
						function() {
							$("#login_form")
									.form(
											'submit',
											{
												url : 'login/customer/validate.do',
												onSubmit : function() {//发送前操作    
													var isValid = $(this).form(
															'validate');
													return isValid; // 返回false终止表单提交
												},
												success : function(data) {
													var data = eval('(' + data
															+ ')');
													if (data.success == true) {
														window.location.href = '<%=basePath%>login/customer/home/index';
													} else {
														$.messager
																.alert(
																		'警告',
																		'<strong><center>'
																				+ data.msg
																				+ '</center></strong>');
													}
												}
											});
						});
	</script>
	<style scoped="scoped">
.textbox {
	height: 20px;
	margin: 0;
	padding: 0 2px;
	box-sizing: content-box;
}
</style>
</body>
</html>